package mylibrary.classloader;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;

public class TestURlClassLoader {

	public static void main(String[] args) throws Exception {
		
		File file = new File("D:\\workspace\\commons-lang-2.4.jar");
		
		URL[] url = new URL[]{file.toURI().toURL()};
		ClassLoader loader = new URLClassLoader(url);
		
		Object o = loader.loadClass("org.apache.commons.lang.StringUtils").newInstance();
		
		System.out.println(o.getClass().getClassLoader());
		System.out.println(o.getClass().getClassLoader().getParent());
		System.out.println(o);
		
		Object d = o.getClass().getMethod("isEmpty", new Class[]{String.class}).invoke(o, new Object[]{"1111"});
		
		System.out.println(d);
		
		
		String s = new String("111111");
		System.out.println(String.class.getClassLoader());
		System.out.println(Thread.currentThread().getContextClassLoader());
		
		
	}
	                                        
}
